<?php
namespace App\Helpers;

class Wx
{
    var $baseUrl = 'https://api.weixin.qq.com';
    var $appId = null;
    var $secret = null;

    public function __construct()
    {
        $this->appId = config('wx.appId');
        $this->secret = config('wx.secret');
    }

    public function code2Session($code)
    {
        $url = $this->baseUrl .
            "/sns/jscode2session?appid=$this->appId&secret=$this->secret&grant_type=authorization_code&js_code=$code";
        $ajax = new Ajax();
        return $ajax->get($url);
    }
}
